/* ==================================================================   
 * Created [2009-4-27 下午11:32:55] by Jon.King 
 * ==================================================================  
 * TSS 
 * ================================================================== 
 * mailTo:jinpujun@hotmail.com
 * Copyright (c) Jon.King, 2009-2012 
 * ================================================================== 
*/

package com.jinhe.tss.cms.workflow;

import java.io.File;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;

import com.jinhe.tss.core.web.dispaly.tree.ITreeNode;
import com.jinhe.tss.core.web.dispaly.tree.TreeAttributesMap;
import com.jinhe.tss.core.web.dispaly.xform.IXForm;

/** 
 * 工作流对象
 */
public class WorkFlow implements ITreeNode, IXForm {

	private Integer code;  // 工作流Code
	private String  name;  // 工作流名称
    private File    file;
    private String  definition;
    
    public WorkFlow(){}
 
    public WorkFlow(String code, String name){
        this.code = Integer.valueOf(code);
        this.name = name;
    }
    
    public String toString() {
        return "code: " + code + ", name: " + name;
    }
    
	/** 本工作流包括的工作流节点集合 */
	private Map<Integer, WorkFlowNode> flowStepsMap = new LinkedHashMap<Integer, WorkFlowNode>();  
	
    public Map<Integer, WorkFlowNode> getFlowStepsMap() {  return flowStepsMap; }

	public Integer getCode() { return code; }
	public String  getName() { return name; }

    public TreeAttributesMap getAttributes() {
        TreeAttributesMap map = new TreeAttributesMap(code, name);
        map.put("icon", "../platform/images/icon/workflow.gif");
        return map;
    }
    
    public File getFile() {
        return file;
    }

    public void setFile(File file) {
        this.file = file;
    }

    public String getDefinition() {
        return definition;
    }

    public void setDefinition(String definition) {
        this.definition = definition;
    }

    public Map<String, Object> getAttributesForXForm(){
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("name", name);
        map.put("file",file);
        map.put("definition", definition);
        return map;
    }
}

